package com.xiyuan.smartutils.extend;

import java.io.Serializable;

/**
 * 整型定义，含值和描述，用于需要描述值时的常量或变量
 *
 * @version v1.0.0 @author lgz 2017-8-27 新建与整理
 */
public final class Int implements Serializable {
    private static final long serialVersionUID = 1L;
    private int value;
    private String desc;
    
    
    public Int() {
    }
    
    public Int(String desc) {
        this.desc = desc;
    }
    
    public Int(int key, String desc) {
        this.desc = desc;
        this.value = key;
    }
    
    public int value() {
        return value;
    }
    
    public String desc() {
        return desc;
    }
    
    public boolean isSuccess() {
        return this.value == 0;
    }
    
    public Int setValue(int value) {
        this.value = value;
        return this;
    }
    
    public Int setDesc(String desc) {
        this.desc = desc;
        return this;
    }
    
    public String toString() {
        return new StringBuilder("Int:[")
                .append("value=").append(value()).append(";")
                .append("desc=").append(desc()).append("]")
                .toString();
    }
}
